<?php

use App\Models\Chat;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

include 'lhr.php';
include "lvbaiyang.php";
include 'qishuo.php';
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});
//支付
Route::get('pay', [\App\Http\Controllers\PayController::class, 'pay']);
//同步
Route::get('sync', [\App\Http\Controllers\PayController::class, 'sync']);
//异步
Route::post('notify', [\App\Http\Controllers\PayController::class, 'notify']);
//获取房源信息
Route::get('house', [\App\Http\Controllers\HouseController::class, 'getHouseList']);
Route::group(['middleware' => 'User'], function () {
    //支付详情
    Route::get('pay_detail', [\App\Http\Controllers\PayController::class, 'payDetail']);
    //经纪人端楼市圈信息
    Route::get('building', [\App\Http\Controllers\BuildingController::class, 'getBuildInfo']);
    //经纪人端删除楼市圈信息
    Route::get('delete', [\App\Http\Controllers\BuildingController::class, 'deleteInfo']);
    //经纪人端发布楼市圈信息
    Route::post('push_build', [\App\Http\Controllers\BuildingController::class, 'pushBuild']);
    Route::get('like',[\App\Http\Controllers\HouseController::class,'likeHouse']);
});
//获取附近房源
Route::get('nearby_house', [\App\Http\Controllers\HouseController::class, 'getNearbyHouse']);

//连接公众号
Route::match(['get','post'],'link_wechat',[\App\Http\Controllers\EasyWechatController::class,'linkWeChat']);
//验证码
Route::get('qr',[\App\Http\Controllers\EasyWechatController::class,'qr']);
//授权登陆页面
Route::get('authorized_login',function (){
    $openId = \request()->get('open_id');
    return view('authorized_login',['open_id'=>$openId]);
});
//授权认证
Route::post('auth',[\App\Http\Controllers\EasyWechatController::class,'userAuth']);
//通过open_id获取用户账号密码
Route::post('qr_post',[\App\Http\Controllers\EasyWechatController::class,'byOpenIdGetUserInfo']);

//客户端获取楼市圈信息
Route::get('build_info',[\App\Http\Controllers\BuildingController::class,'clientGetBuildInfo']);
Route::get('aaa',function (){
    $chatMessage = Chat::whereIn('uid', [6,3])->whereIn('tid', [6,3])->get()->toArray();
    print_r($chatMessage);

});
